package getsubs.filenameguesser;

import org.hamcrest.text.pattern.PatternComponent;
import static org.hamcrest.text.pattern.Patterns.*;

/**
 * Patterns used by RegExpGuesser.
 * @author Andrea
 */
class RegExpGuesserPatterns {

    private RegExpGuesserPatterns() {}

    public static PatternComponent filename() {
        return sequence(showName(),".",season(),episode(),rubbish(),".avi");
    }

    public static PatternComponent showName() {
        return capture("showname",  oneOrMore(anyCharacterNotIn(".")));
    }

    public static PatternComponent season() {
        return sequence("S",capture("season", twoDigits()));
    }

    public static PatternComponent episode() {
        return sequence("E",capture("episode", twoDigits()));
    }
    
    public static PatternComponent rubbish() {
        return reluctantOneOrMore(anyCharacter());
    }

    public static PatternComponent twoDigits() {
        return exactly(2, anyCharacterInCategory("Digit"));
    }


    private static PatternComponent reluctantOneOrMore(Object o) {
        return new ReluctantOneOrMore(toPattern(o));
    }
}
